package com.wondersgroup.drools.chapter25;

import com.wondersgroup.drools.BaseTest;
import com.wondersgroup.drools.model.Person;
import org.junit.Test;
import org.kie.api.runtime.KieSession;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MapAndListTest extends BaseTest {

    @Test
    public void testMapAndList(){
        KieSession kieSession = this.getKieSessionBySessionName("mapAndList-rules");

        Map<String,Integer> map = new HashMap<>();
        map.put("a",1);
        map.put("b",2);

        List<Person> list = new ArrayList<>();
        list.add(getPerson(18));
        list.add(getPerson(20));

        kieSession.insert(map);
        kieSession.insert(list);

        kieSession.fireAllRules();
        kieSession.dispose();

    }

    private Person getPerson(int age){
        Person p = new Person();
        p.setAge(age);
        return p;
    }
}
